<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Models\Candy\StoryImages;

class CreateCandyStoryImagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $sql = "CREATE TABLE `".StoryImages::getFullTableTable()."` (
  `".StoryImages::DB_FIELD_ID."` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `".StoryImages::DB_FIELD_STORY_ID."` int(11) unsigned NOT NULL COMMENT '故事id',
  `".StoryImages::DB_FIELD_IMAGE_SOURCE."` tinyint(4) NOT NULL DEFAULT '1' COMMENT '来源1阿里云2url',
  `".StoryImages::DB_FIELD_IMAGE_VALUE."` varchar(4096) NOT NULL DEFAULT '' COMMENT '文件路径',
  `".StoryImages::DB_FIELD_SORT."` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
  `".StoryImages::DB_FIELD_IS_PRIVATE."` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '私密图片0不是1是',
  `".StoryImages::DB_FIELD_CREATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `".StoryImages::DB_FIELD_UPDATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `".StoryImages::DB_FIELD_DELETED_AT."` timestamp NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='糖果故事图集表';";
        DB::connection()->getPdo()->exec($sql);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop(StoryImages::getFullTableTable());
    }
}
